import os
from multiprocessing import Queue, Process


def fun(name, q):
    data = {name: os.getpid()}
    print('插入数据：', data)
    q.put(data)


if __name__ == "__main__":
    q = Queue(5)
    jobs = []
    print(q.full())
    for i in range(5):
        p = Process(target=fun, args=(i, q))
        jobs.append(p)
        p.start()
    print(q.full())
    for i in range(5):
        data = q.get()
        print('获取数据：', data)

    for job in jobs:
        job.join()
